package dl.bukkit.myststus.loader;

import dl.bukkit.myststus.MyStatus;
import dl.bukkit.myststus.api.listener.ListenerManager;
import dl.bukkit.myststus.command.CommandHandler;
import dl.bukkit.myststus.configuration.ConfigurationManager;
import dl.bukkit.myststus.hook.HookManager;
import dl.bukkit.myststus.library.container.ListContainer;
import dl.bukkit.myststus.task.TaskManager;
import dl.bukkit.myststus.function.ComponentManager;
import dl.bukkit.myststus.vexshow.VexHudManager;

import java.util.LinkedList;

public class LoaderManager {

    private final ListContainer<Loader> container;

    public LoaderManager(MyStatus plugin) {
        this.container = new ListContainer<>(new LinkedList<>(), MyStatus.class);
        container.register(HookManager.class, plugin);
        container.register(ConfigurationManager.class, plugin);
        container.register(ComponentManager.class, plugin);
        container.register(CommandHandler.class, plugin);
        container.register(ListenerManager.class, plugin);
        container.register(VexHudManager.class, plugin);
        container.register(TaskManager.class, plugin);
    }

    public void register() {
        container.getList().forEach(Loader::onLoad);
    }

    public void staring() {
        container.getList().forEach(Loader::staring);
    }

    public void stopping() {
        container.getList().forEach(Loader::stopping);
    }
}
